<template>
  <div>
    <table-form @next="sales10Ctrl">
      <template slot="title">
        <h2 class="fromDivTit">出售成功</h2>
      </template>
      <div class="divZk">
        <ul
          ref="sale10Form"
          :model="sale10Form"
        >
          <li>
            <p><i>售价:</i>{{ sale10Form.salePrice }}</p>
            <p>
              <i>{{ lastPayment.name }}:</i>{{ lastPayment.feeDollar }}
            </p>
          </li>
          <li>
            <p><i>起售日:</i>{{ dateFormat2(sale10Form.createdTime) }}</p>
            <p><i>出售日:</i>{{ dateFormat2(sale10Form.completeTime) }}</p>
          </li>
          <li>
            <p>
              <i>附件:</i>
              <span
                v-for="(item, index) in getFileList(sale10Form.contactFilePath)"
                :key="index"
              ><a
                :href="sale10Form.contactFilePath.split(',')[index]"
                target="_blank"
              >
                {{ item }}
              </a></span>
            </p>
          </li>
        </ul>
      </div>
      <template slot="footer">
        <div class="dialog-footer">
          <el-button type="primary" @click="nextList">返回列表</el-button>
        </div>
      </template>
    </table-form>
  </div>
</template>

<script>
import TableForm from '../../../lease/components/tableForm'
import { saleDetail } from '@/api/sale'
import { getFileList, dateFormat2 } from '@/utils/common'

export default {
  components: {
    TableForm
  },
  props: {
    id: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      getFileList,
      dateFormat2,
      sale10Form: {
        salePrice: '',
        paymentList: [],
        completeTime: '',
        contactFilePath: '',
        id: ''
      }
    }
  },
  computed: {
    lastPayment() {
      const list = this.sale10Form.paymentList
      return list.length - 1 >= 0 ? list[list.length - 1] : {}
    }
  },
  created() {
    this.getsaleDetail()
  },
  methods: {
    async getsaleDetail() {
      this.sale10Form.id = this.id
      var sale10Res = await saleDetail(this.id)
      this.sale10Form = sale10Res.data
    },
    sales10Ctrl() {
      this.$emit('next')
    },
    nextList() {
      this.$router.push({ path: 'sale' })
    }
  }
}
</script>
<style lang="scss" scoped>
.dialog-footer {
  text-align: right;
  padding-top: 10px;
}
.divZk {
  margin-bottom: 20px;
}
.divZk ul li {
  display: flex;
  align-items: center;
  margin-bottom: 5px;
}
.divZk ul li {
  color: #101010;
  font-size: 12px;
  width: 100%;
}
.divZk ul li i {
  color: #b3b3b3;
  text-align: right;
  display: inline-block;
  margin-right: 10px;
}
.divZk ul li p {
  width: 33.3%;
  text-align: left;
}
.divZk ul.auto li {
  width: auto;
}
.divZk ul.auto li {
  flex-wrap: wrap;
}
.divZk ul.auto li p {
  display: block;
  width: 100%;
  margin-bottom: 10px;
}
.divZk ul.auto li p em {
  margin-right: 20px;
}
.divZk ul li span {
  color: #5ac6b7;
}
</style>
